package com.yociyy.security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.access.AccessDeniedHandler;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.yociyy.security.authentication.YoCiAccessDeniedHandler;
import com.yociyy.security.authentication.YoCiAuthenticationEntryPoint;

import lombok.AllArgsConstructor;

/**
 * @author: YoCiyy
 * @date: 2020/7/4
 */
@AllArgsConstructor
public class AuthenticationBeanConfig {

	private final ObjectMapper objectMapper;

	@Bean
	public AccessDeniedHandler accessDeniedHandler() {
		return new YoCiAccessDeniedHandler(objectMapper);
	}

	@Bean
	public AuthenticationEntryPoint authenticationEntryPoint() {
		return new YoCiAuthenticationEntryPoint(objectMapper);
	}

}
